package cn.trip.service.user;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.trip.dao.user.UserMapper;
import cn.trip.pojo.Safe_question;
import cn.trip.pojo.Trip_bill;
import cn.trip.pojo.Trip_question;
import cn.trip.pojo.Trip_room;
import cn.trip.pojo.Trip_tourist;
import cn.trip.pojo.Trip_user;

@Service
public class UserServiceImpl implements UserService{

	@Resource
	private UserMapper userMapper;

	@Override
	public Trip_user getUser(String userCode, String password) {
		return userMapper.getUser(userCode, password);
	}

	@Override
	public boolean modifyInfo(Trip_user user) {
		boolean flag = false;
		if(userMapper.modifyInfo(user)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public List<Trip_bill> getBillsById(String userCode,int u_id,int proType,int currentPageNo,int pageSize) {
		return userMapper.getBillsById(userCode,u_id,proType,(currentPageNo-1)*pageSize,pageSize);
	}

	@Override
	public Trip_bill getHotelBillsBybid(int b_id) {
		return userMapper.getHotelBillsBybid(b_id);
	}

	@Override
	public Trip_bill getTravelBillsBybid(int b_id) {
		return userMapper.getTravelBillsBybid(b_id);
	}

	@Override
	public List<Trip_tourist> getTourists(int b_id) {
		return userMapper.getTourist(b_id);
	}

	@Override
	public List<Trip_bill> getTicketBills(int u_id,int proType, Integer currentPageNo,
			Integer pageSize) {
		return userMapper.getTicketBills(u_id,proType, (currentPageNo-1)*pageSize, pageSize);
	}

	@Override
	public int count(int u_id, int proType) {
		return userMapper.count(u_id, proType);
	}

	@Override
	public Trip_bill getTicketInfo(int b_id, int proType) {
		return userMapper.getTicketInfo(b_id, proType);
	}

	@Override
	public List<Trip_bill> getAllBills(String userCode,int currentPageNo,int pageSize) {
		return userMapper.getAllBills(userCode,(currentPageNo-1)*pageSize,pageSize);
	}

	@Override
	public boolean delete(int b_id) {
		boolean flag = false;
		if(userMapper.delete(b_id)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public Trip_user getPawUser(String userCode) {
		return userMapper.getPawUser(userCode);
	}

	@Override
	public boolean modifyPaw(String password, String userCode) {
		boolean flag = false;
		if(userMapper.modifyPaw(password, userCode)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public Trip_user judgePwd(String userCode, String password) {
		return userMapper.judgePwd(userCode, password);
	}

	@Override
	public Trip_user getQuestionBySid(int s_id) {
		return userMapper.getQuestionBySid(s_id);
	}

	@Override
	public Safe_question judgeQuestion(int id) {
		return userMapper.judgeQuestion(id);
	}

	@Override
	public List<Trip_question> getAllQuestions() {
		return userMapper.getAllQuestions();
	}

	@Override
	public boolean modifyQuestion(int questionId, Date modifyDate, int id,String answer) {
		boolean flag = false;
		if(userMapper.modifyQuestion(questionId, modifyDate, id,answer)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public boolean addAnswer(int questionId, String answer, Date createDate,String userCode) {
		boolean flag = false;
		if(userMapper.addAnswer(questionId, answer, createDate,userCode)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public Safe_question getQ_id(String userCode) {
		return userMapper.getQ_id(userCode);
	}

	@Override
	public boolean addUser(String userCode, String userName, String password,
			Date createDate, String userEmail, int s_id, String userPhone,
			String userAddress, Date birth, int sex) {
		boolean flag =false;
		if(userMapper.addUser(userCode, userName, password, createDate, userEmail, s_id, userPhone, userAddress, birth, sex)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public Safe_question judQuestion(int questionId, String answer) {
		return userMapper.judQuestion(questionId, answer);
	}

	@Override
	public boolean modifyPwd(String password, Date modifyDate, String userCode) {
		boolean flag = false;
		if(userMapper.modifyPwd(password, modifyDate, userCode)>0){
			flag = true;
		}
		return flag;
	}

	@Override
	public Safe_question getThisQuestion(String userCode) {
		return userMapper.getThisQuestion(userCode);
	}

	@Override
	public Trip_question getThisQuestionByQ_id(int q_id) {
		return userMapper.getThisQuestionByQ_id(q_id);
	}

	@Override
	public boolean modifyIspay(Integer b_id, Integer isPay) {
		boolean flag = false;
		if(userMapper.modifyIspay(b_id, isPay)>0){
			flag = true;
		}
		return flag;
	}
	
	
}
